package com.accp.vehiclecare.biz.zbbiz;

import com.accp.vehiclecare.dao.zbdao.StationMapper;
import com.accp.vehiclecare.pojo.Station;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class PostBiz {
    @Autowired(required = false)
    private StationMapper sdao;

    /**
     * 查询全部岗位
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED, readOnly = true)
    public PageInfo<Station>SelectPost(Integer p,Integer s){
        PageHelper.startPage(p,s);
        return new PageInfo<Station>(sdao.SelectAllStaion());
    }

    /**
     * 新增岗位
     * @param name
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean addStation(String name){
        return 0!=sdao.insertStation(name);
    }

    /**
     * 删除岗位
     * @param sid
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean removeStation(Integer sid){
        return 0!=sdao.deleteByPrimaryKey(sid);
    }
}
